import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import store from './store'

// 引入路由组件
import { Router, Route, hashHistory, IndexRedirect } from 'react-router'

// 引入 Login 组件
import LoginPage from './views/LoginPage'
import Home from './views/Home'
import Detail from './views/Detail'

class App extends React.Component {
    render() {
        return (<>
            {this.props.children}
        </>)
    }
}

const router = (<Router history={hashHistory}>
    <Route path="/" component={App}>
        <IndexRedirect to="login" />
        <Route path="login" component={LoginPage} />
        <Route path="home" component={Home} />
        <Route path="detail/:id" component={Detail} />
    </Route>
</Router>)


ReactDOM.render((
    <Provider store={store}>
        {router}
    </Provider>
), document.getElementById('root'))